import { createContext } from 'react'

// 创建 context
const CommonContext = createContext(null);

//action
export const commonType = {
  SET_TABBAR: 'SET_TABBAR'
}
export const setTabBar = (tabBar) => {
  return {
    type: commonType.SET_TABBAR,
    payload: { tabBar }
  }
}

//reducer
const initState = { tabBar: '工作台' };
const reducer = (state, action) => {
  let { payload } = action;
  switch (action.type) {
    case commonType.SET_TABBAR:
      return { ...state, ...payload };
    default:
      return state;
  }
}

export {
  CommonContext,
  initState,
  reducer
};